package com.chixing.day05.Fuxi;

public class CreditAccount extends Account {
    private float maxOverdraw;
    private float creditScore;

    public float getMaxOverdraw() {
        return maxOverdraw;
    }

    public void setMaxOverdraw(float maxOverdraw) {
        this.maxOverdraw = maxOverdraw;
    }

    public float getCreditScore() {
        return creditScore;
    }

    public void setCreditScore(float creditScore) {
        this.creditScore = creditScore;
    }


    public CreditAccount(int accountId, String accountName, String accPassword, long accTelno, float accBalance, float annualInterestRate, int accType, float maxOverdraw, float creditScore) {
        super(accountId, accountName, accPassword, accTelno, accBalance, annualInterestRate, accType);
        this.maxOverdraw = maxOverdraw;
        this.creditScore = creditScore;

    }

    public void withdraw(float money) {
        if (money < getAccBalance()) {
            setAccBalance(getAccBalance() - money);
        } else {
            float maxOverdrawMoney = money - getAccBalance();
            if (maxOverdrawMoney <= maxOverdraw) {
                setAccBalance(0);
                maxOverdraw -= maxOverdrawMoney;
            } else {
                System.out.println("可用额度不足,不能透支");
            }
        }
    }
}
